git checkout dev
git pull

cp docker-compose.yml /root/project/docker/livefind/
cp config.docker.yaml /root/project/docker/livefind/config/

version=0.1.1.`git rev-list HEAD --count`
docker build --network=host -t jd-live-find:${version} .
cd /root/project/docker/livefind
CONF=.env
set_key_value() {
    local key=${1}
    local value=${2}
    if [ -n $value ]; then
        local current=$(sed -n -e "s/^\($key = \)\([^ ']*\)\(.*\)$/\2/p" $CONF) # value不带单引号
        if [ -n $current ];then
            echo "setting $CONF : $key = $value"
            value="$(echo "${value}" | sed 's|[&]|\\&|g')"
            sed -i "s|^[#]*[ ]*${key}\([ ]*\)=.*|${key}=${value}|" ${CONF}
        fi
    fi
}

set_key_value "JD_LIVE_FIND" ${version}

docker-compose up -d